home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1633 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: maths.tcd.ie!not-for-mail
  2. From: dwmalone@maths.tcd.ie (David Malone)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Must I free my linked lists? (GCC)
  5. Date: 22 Jan 1996 09:59:57 -0000
  6. Organization: Dept. of Maths, Trinity College, Dublin, Ireland.
  7. Message-ID: <4dvn6t$lc3@hamilton.maths.tcd.ie>
  8. References: <4dudic$aif@vixen.cso.uiuc.edu> <4dusp9$7k3@senator-bedfellow.MIT.EDU>
  9. NNTP-Posting-Host: hamilton.maths.tcd.ie
  10.  
  11. rid@red-branch.MIT.EDU (Shawna Grimm) writes:
  12.  
  13. >Unknown (Dannyman@uiuc.edu) typed in the following on 21 Jan 1996 22:09:16 GMT:
  14. >:    I'm writing a program that makes use of dynamic memory allocation through
  15. >: linked lists using malloc() ... from an implementation PoV there's no need
  16. >: to flush this stuff as after the queue is created it's output and the
  17. >: program exits. My question is;
  18.  
  19. >Yes, you _should_ free any memory that you allocate in your program. 
  20. >Memory that is allocated and not freed will not be returned to the system 
  21. >unless you turn the machine off, so if you want your memory back, you 
  22. >must free it. Personally, I would prefer to use AllocMem() or AllocVec()
  23. >(with FreeMem() and FreeVec() ofcourse).
  24.  
  25. I think the memory is freed in when you use malloc - in gcc or SAS/C.
  26. Weither this is in malloc's spec is another matter. I think
  27. memory you malloc ( as opposed to AllocMem'ed ) seems to be tracked
  28. and freed at exit. I noticed this when I was testing something I was
  29. writing on unix, and hadn't finished the memory stuff. It allocates
  30. about 8MB, which went fine, but I was quite shoked to see that I could
  31. run it twice in a row ( I only have 10MB of ram ).
  32.  
  33.     David.
  34.